﻿$(function () {
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var calendar = $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        selectable: false,
        selectHelper: false,
        editable: false,

        eventClick: function (calEvent, jsEvent, view) {
            location.href = "/Events/" + calEvent.id;
        },

        loading: function (bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        },

        events: function (start, end, callback) {

            var input = {
                start: $.fullCalendar.formatDate(start, "MM/dd/yyyy"),
                end: $.fullCalendar.formatDate(end, "MM/dd/yyyy")
            };

            Ajax({
                url: "/Events/GetEvents",
                data: JSON.stringify(input),
                success: function (data) {
                    callback(data);
                },
                complete: function () {

                }
            });
        }
    });
});
